<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OCR识别</title>
    <link rel="stylesheet" href="/static/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>OCR识别</h1>
            <p class="subtitle">智能文字识别</p>
        </header>

        <div class="main-content">


            <!-- 文件上传区域 -->
            <div class="upload-section">
                <div class="file-history">
                    <h3>我的文件</h3>
                    <div class="file-list" id="fileList">
                        <p class="no-files">暂未上传过任何文件</p>
                    </div>
                </div>

                <div class="upload-area" id="uploadArea">
                    <div class="upload-content">
                        <i class="fas fa-cloud-upload-alt upload-icon"></i>
                        <p class="upload-text">点击上传文件试试吧</p>
                        <p class="upload-desc">
                            支持jpg、png、bmp、pdf、tiff、单帧gif等格式，<br>
                            上传单个文件大小不超过5M
                        </p>
                        <input type="file" id="fileInput" multiple accept=".jpg,.jpeg,.png,.bmp,.pdf,.tiff,.gif">
                        <div class="upload-buttons">
                            <button class="btn btn-primary" onclick="selectFiles()">
                                <i class="fas fa-plus"></i> 上传文件(单个/批量上传)
                            </button>
                        </div>
                    </div>
                </div>

                <!-- 文件选择控制 -->
                <div class="file-controls" id="fileControls" style="display: none;">
                    <div class="select-info">
                        <label>
                            <input type="checkbox" id="selectAll"> 本页全选
                        </label>
                        <span id="selectedCount">已经选0个文件</span>
                    </div>
                    <div class="control-buttons">
                        <button class="btn btn-secondary" id="multiSelectBtn">多选</button>
                        <button class="btn btn-primary" id="processBtn" onclick="processFiles()">开始识别</button>
                    </div>
                </div>
            </div>

            <!-- 结果显示区域 -->
            <div class="result-section" id="resultSection" style="display: none;">
                <div class="result-tabs">
                    <button class="tab-btn active" onclick="switchTab('preview')">图片预览</button>
                    <button class="tab-btn" onclick="switchTab('text')">识别结果</button>
                    <button class="tab-btn" onclick="switchTab('json')">JSON结果</button>
                </div>
                <div class="result-content">
                    <div id="previewResult" class="result-panel active">
                        <div class="image-preview-container">
                            <div class="image-preview">
                                <img id="previewImage" src="" alt="预览图片" style="display: none;">
                                <canvas id="previewCanvas" style="display: none;"></canvas>
                                <div class="text-boxes" id="textBoxes"></div>
                                <p id="previewPlaceholder">暂无图片预览</p>
                            </div>
                            <div class="preview-info">
                                <h4>图片信息</h4>
                                <div id="imageInfo">
                                    <p>文件名: <span id="fileName">-</span></p>
                                    <p>文件大小: <span id="fileSize">-</span></p>
                                    <p>识别状态: <span id="ocrStatus">-</span></p>
                                </div>
                                <div class="preview-controls">
                                    <button class="btn btn-secondary btn-sm" onclick="toggleTextBoxes()">
                                        <i class="fas fa-eye" id="toggleIcon"></i> <span id="toggleText">显示文本框</span>
                                    </button>
                                </div>
                            </div>
                            // ... existing code ...
                        </div>
                    </div>
                    <div id="textResult" class="result-panel">
                        <div class="result-text" id="resultText"></div>
                    </div>
                    <div id="jsonResult" class="result-panel">
                        <pre id="resultJson"></pre>
                    </div>
                </div>
                <div class="result-actions">
                    <button class="btn btn-primary" onclick="copyResult()">
                        <i class="fas fa-copy"></i> 复制结果
                    </button>
                    <button class="btn btn-secondary" onclick="downloadResult()">
                        <i class="fas fa-download"></i> 下载结果
                    </button>
                </div>
            </div>
        </div>

        <!-- 加载动画 -->
        <div class="loading" id="loading" style="display: none;">
            <div class="loading-spinner"></div>
            <p>正在识别中，请稍候...</p>
        </div>
    </div>

    <script src="/static/script.js"></script>
</body>
</html>